from django.contrib import admin
from .models import Author, Genre, Book

@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_display = ('title', 'author', 'display_genre')
    list_filter = ('author', 'genre')

    def display_genre(self, obj):
        return ', '.join(genre.name for genre in obj.genre.all())
    display_genre.short_description = 'Genre'

admin.site.register(Author)
admin.site.register(Genre)
